<?php
function spliter_browser( $content , $pagename ,$link=false , $popen = true){
if(!is_admin())return fatal_error('Maaf anda tidak ada akses'); 

my_set_file_js(
	array(
		'components/system/jquery/jquery-accordion/lib/chili-1.7.pack.js',
		'components/system/jquery/jquery-accordion/lib/jquery.easing.js',
		'components/system/jquery/jquery-accordion/lib/jquery.dimensions.js',
		'components/system/jquery/jquery-accordion/jquery.accordion.js' 
	)
);	

my_set_code_js('
// second simple accordion with special markup
		jQuery(\'#navigation\').accordion({
			active: false,
			header: \'.head\',
			navigation: true,
			event: \'mouseover\',
			fillSpace: true,
			animated: \'easeslide\'
		});
');

my_set_code_css('  
#navigation0 span.head{
	cursor:pointer;   
	padding: 5px 5px 5px 8px;
	border-left: 10px solid #000;
	border-right: 10px solid #FF3C3C;
	color:#000;
	margin-bottom:1px;
	background-color:brown;
	font-weight:bold;
}  
#navigation0 span.head a{
	color:#fff;
}
#blueblock{
height:100%;
width: 180px; 
margin: 24px 0 1em 0;
padding: 0 0 1em 0;
margin-bottom: 1em; 
background-color: #fff;
border-right:2px solid #000;
color: #333;
}


* html #blueblock{ /*IE 6 only */
w\idth: 147px; /*Box model bug: 180px minus all left and right paddings for #blueblock */
}

#blueblock ul{
	list-style: none;
	margin: 0;
	padding: 0;
	border: none;
}

#blueblock li {
	border-bottom: 1px solid #CDCDCD;
	margin: 0;
}

#blueblock li a{
	display: block;
	padding: 5px 5px 5px 8px;
	border-left: 10px solid #000;
	border-right: 10px solid #FF3C3C;
	background-color: #D40300;
	color: #fff;
	text-decoration: none;
	width: 100%;
	font:11px verdana;
}

html>body #blueblock li a{ /*Non IE6 width*/
	width: auto;
}

#blueblock li a:hover{
	border-left: 10px solid #1c64d1;
	border-right: 10px solid #5ba3e0;
	background-color: #BD9796;
	color: #fff;
	font:11px verdana;
}  


#navigation0 span.head {
	cursor:pointer; 
	display:block; 
}
 
#blueblock li span {  
	display: block;
	padding: 5px 5px 5px 8px;
	border-left: 10px solid #000;
	border-right: 10px solid #508fc4;
	background-color: red;
	color: #fff;
	text-decoration: none;
	width: 100%;
	font:11px verdana;
}
html>body #blueblock span{ /*Non IE6 width*/
width: auto;
}

#blueblock li span{
border-left: 10px solid #000;
border-right: 10px solid #5ba3e0;
background-color: #1c64d1;
color: #fff;
font:12px verdana;
font-weight:bold;
}  

#admin_title{ 
width:98%;
float:right;
font:16px verdana;
font-weight:bold;
border-bottom:1px solid #CDCDCD;
padding:0 0 5px 10px;
} 
#button_title{ 
margin-left:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border:2px solid red;
width:100px;
float:right;
text-align:center;
font:12px verdana;
font-weight:bold; 
background:#ECECEC;
padding: 2px 5px 2px 5px;
}
');
	$view = '<table width="100%" height="100%" cellspacing="0" cellpadding="0"><tr>';
	$view .= '<td width="10%" valign="top" align="right">
	<div id="blueblock">
	<ul id="navigation0">
		 <span class="head">
			<a href="index.php?com=konfigurasi&task=referensi">Referensi</a></span>
			<ul>
			<li><a href="index.php?com=pendidikan" title="Job Spesification - Pendidikan">Pendidikan</a></li>
			<li><a href="index.php?com=kelompok_hobi" title="Konfigurasi Pendidikan">Kelompok hobi</a><li>
			<!-- li><a href="index.php?com=profesi" title="Profesi">Profesi</a></li -->
			<li><a href="index.php?com=hubungan_keluarga" title="Hub. Keluarga">Hub. Keluarga</a></li>
			<li><a href="index.php?com=bank" title="Data bank">Data bank</a></li>
			<li><a href="index.php?com=a_hari_libur" title="Hari Libur">Hari Libur</a></li>
			<li><a href="index.php?com=jabatan_physical" title="Kualifikasi">Data kualifikasi</a></li> 
			<li><a href="index.php?com=kompetensi_jenis" title="Jenis kompetensi">Jenis kompetensi</a></li> 
			</ul>
		 <span class="head"><a href="index.php?com=konfigurasi&task=organisasi">Organisasi</a></span>
			<ul>
			<li><a href="index.php?com=pos_biaya" title="Data Struktur - Cost Centre">Cost Centre</a></li>
			<li><a href="index.php?com=unit" title="Unit/ Cabang">Unit/ Cabang</a></li>	
			<li><a href="index.php?com=departemen" title="Departemen">Departemen</a></li>	
			<li><a href="index.php?com=org_status_karyawan" title="Status karyawan">Status karyawan</a></li>	
			<li><a href="index.php?com=golongan_jabatan" title="Golongan Jabatan">Golongan jabatan</a></li> 
			<li><a href="index.php?com=grade" title="Grade">Grade</a></li>
			<li><a href="index.php?com=gol_grade" title="Pengelompokan Grade">Pengelompokan Grade</a></li>	
			<li><a href="index.php?com=jabatan" title="Data Struktur - Direktorat">Setting Struktur</a></li>			
			<li><a href="index.php?com=struktur_tree" title="Data Struktur - Struktur Organisasi">Struktur Organisasi</a></li>
			<li><a href="index.php?com=jabatan_man_power" title="Man Power">Kebutuhan jabatan</a></li>
			<li><a href="index.php?com=jabatan_description" title="Job Description">Deskripsi jabatan</a></li>
			<li><a href="index.php?com=kompetensi&top=1" title="Kompetensi">Kompetensi</a></li>
			<li><a href="index.php?com=jabatan_specification" title="Job Specification">Spesifikasi jabatan</a></li>
			<li><a href="index.php?com=keluarga_jabatan" title="Job family">Kelompok pekerjaan</a></li>
			<li><a href="index.php?com=jalur_karir" title="Career path">Jalur karir</a></li>
			<!-- li><a href="index.php?com=nipar" title="Nipar">Nipar</a></li -->
			</ul>
		 
		<span class="head"> <a href="index.php?com=konfigurasi&task=penggajian">Penggajian</a></span>
			<ul>
			<li><a href="index.php?com=struktur_gaji" title="Struktur Gaji">Struktur Gaji</a></li> 
			<li><a href="index.php?com=pr_sk_tunjangan" title="SK Tunjangan">SK Tunjangan</a></li>
			<li><a href="index.php?com=jurnal_gaji" title="Jurnal Gaji">Jurnal Gaji</a></li>	
			<li><a href="index.php?com=komponen_gaji&jid=1" title="Tunjangan">Tunjangan</a></li>
			<li><a href="index.php?com=komponen_gaji&jid=2" title="Potongan">Potongan</a></li>
			<li><a href="index.php?com=komponen_gaji&jid=3" title="Subsidi">Subsidi</a></li>
			<li><a href="index.php?com=pr_tarif_pajak" title="Tarif Pajak">Tarif Pajak</a></li>
			<li><a href="index.php?com=konfigurasi_pajak" title="Konfigurasi">Konfigurasi Pajak</a></li>
			<li><a href="index.php?com=yearly_income" title="Yearly Income">Yearly Income</a></li>
			</ul>
		 
		<span class="head"><a href="index.php?com=konfigurasi&task=diklat">Diklat</a></span>
			<ul>	
			<li><a href="index.php?com=type_pelatihan" title="Type Pelatihan">Type Pelatihan</a></li>
			<li><a href="index.php?com=materi_pelatihan" title="Materi Pelatihan">Materi Pelatihan</a></li>
			<li><a href="index.php?com=kategori_pelatihan" title="Kategori Pelatihan">Kategori Pelatihan</a></li> 
			<li><a href="index.php?com=penyelenggara_pelatihan" title="Penyelenggara Pelatihan">Penyelenggara Pelatihan</a></li> 
			</ul>
		
		<span class="head"><a href="index.php?com=konfigurasi&task=admin">Administrasi</a></span>
			<ul>		
			<!-- <li><a href="index.php?com=faktor_insentif" title="Job Spesification - Faktor Insentif">Faktor Insentif</a></li>-->	
			<!-- <li><a href="index.php?com=faktor_insentif_skor" title="Job Spesification - Faktor Insentif Score">Faktor Insentif Score</a></li>-->	
			<li><a href="index.php?com=kelompok_pengantian" title="Biaya Kesehatan">Biaya Kesehatan</a></li> 
			<li><a href="index.php?com=grievance" title="Grievance">Grievance</a></li>
			<li><a href="index.php?com=jadwal_kerja" title="Setting Waktu Kerja">Setting Waktu Kerja</a></li>
			<li><a href="index.php?com=spd_biaya" title="Komponen Perjalanan Dinas">Komponen Perj. Dinas</a></li>
			<li><a href="index.php?com=spd_non_karyawan" title="Data Non Karyawan (SPD)">Data Non Karyawan (STPD)</a></li> 		
			<li><a href="index.php?com=spd_jarak_tempuh" title="Transport Tambahan (STPD)">Transport (STPD)</a></li>
			<li><a href="index.php?com=spd_biaya_golongan_jabatan" title="Biaya Golongan Jabatan (STPD)">By. Gol. Jabatan (STPD)</a></li>
			<li><a href="index.php?com=spd_biaya_jabatan" title="Honor &amp; Saku (STPD)">Honor &amp; Saku (STPD)</a></li>
			<li><a href="index.php?com=unsur_evaluasi" title="Unsur Evaluasi">Unsur Evaluasi Appraisal</a></li>
			<!-- li><a href="index.php?com=konfigurasi_ttd" title="Konfigurasi Penandatangan">Penandatangan</a></li -->			
			<li><a href="index.php?com=paket_mcu" title="Paket MCU">Paket MCU</a></li>			
			<li><a href="index.php?com=seragam" title="Jenis Seragam">Jenis Seragam</a></li>			
			<li><a href="index.php?com=konfigurasi_konstanta" title="Konstanta">Konstanta</a></li>		
			<li><a href="index.php?com=msg_setting" title="Text Gaji">Text Gaji</a></li>			
			</ul>
		
	</ul>
	</div>  
	</td>';
	$view .= '<td width="90%" valign="top">' ;
	
	$button = '';
	$task = isset( $_GET['task']) ?  $_GET['task'] : '' ;
	if($_GET['com']=='pr_gol_jabatan'){
		if($task ==''){
			$button .=  ' <div id="button_title"><a '.($popen ? 'rel="facebox" ': '').' href="'.($link ? $link: 'javascript:void;').'">Tambah data</a></div>' ;	
		}	
	}elseif($_GET['com']=='pr_sk_tunjangan'){
		if($task ==''){
			$button .=  ' <div id="button_title"><a '.($popen ? 'rel="facebox" ': '').' href="'.($link ? $link: 'javascript:void;').'">Tambah data</a></div>' ;	
		}			
	}elseif($_GET['com']=='grade'){
		if($task ==''){
			$button .=  ' <div id="button_title"><a href="index.php?com=grade&task=editgrade">Tambah data</a></div>' ;	
		}			

	}else{
		$adds = array('jabatan',
			'kompetensi',
			'unit',
			'pos_biaya' , 
			'departemen' , 
			'kompetensi_jenis' , 
			'org_status_karyawan' , 
			'keluarga_jabatan',
			'komponen_gaji',
			'pendidikan',
			'faktor_insentif',
			'kelompok_hobi',
			'jabatan_physical',
			'golongan_jabatan',
			'grade',
			'jurnal_gaji',
			'materi_pelatihan',
			'kategori_pelatihan',
			'penyelenggara_pelatihan',
			'kelompok_pengantian',
			'spd_biaya',
			'spd_jarak_tempuh',
			'spd_jenis_non_karyawan',
			'spd_non_karyawan',
			'grievance',
			'jadwal_kerja',
			'spd_biaya_golongan_jabatan',
			'spd_biaya_jabatan',
			'unsur_evaluasi',
			'profesi',
			'pr_tarif_pajak',
			'bank',
			'jenis_peringatan',
			'hubungan_keluarga',
			'type_pelatihan',
			'yearly_income',
			'seragam',
		);
		$add = $_GET['com'];
		if(in_array($add,$adds))
		$button .=  ' <div id="button_title"><a '.($popen ? 'rel="facebox" ': '').' href="'.($link ? $link: 'javascript:void;').'">Tambah data</a></div>' ;
	}
	if($_GET['com']=='konfigurasi_ttd'){
		$task = isset($_GET['task']) ? $_GET['task'] :'' ;
		if( $task=='edit'){
			$button .='<div id="button_title"><a href="index.php?com=konfigurasi_ttd">Back</a></div>' ;
			$button .='<div id="button_title"><a href="javascript:void;" onclick="javascript:document.formDataSubmit.submit()">Simpan</a></div>' ;
		}else{
			$button .='<div id="button_title"><a href="index.php?com=konfigurasi_ttd&task=edit">Edit</a></div>' ;
		}	
	}	
	if($_GET['com']=='konfigurasi_konstanta'){
		$task = isset($_GET['task']) ? $_GET['task'] :'' ;
		if( $task=='edit'){
			$button .='<div id="button_title"><a href="index.php?com=konfigurasi_konstanta">Back</a></div>' ;
			$button .='<div id="button_title"><a href="javascript:void;" onclick="javascript:document.formDataSubmit.submit()">Simpan</a></div>' ;
		}else{
			$button .='<div id="button_title"><a href="index.php?com=konfigurasi_konstanta&task=edit">Edit</a></div>' ;
		}	
	}	
	if($_GET['com']=='kompetensi'){
		$task = isset($_GET['task']) ? $_GET['task'] :'' ;
		$button .='<div id="button_title"><a href="javascript:void;" onclick="javascript:window.open(\'index.php?com=report&task='.$task .'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');">Cetak</a></div>' ;
	}elseif($_GET['com']=='struktur_gaji'){
		$task = isset($_GET['task']) ? $_GET['task'] :'' ;
		if($task==''){
			$button .=  ' <div id="button_title"><a '.($popen ? 'rel="facebox" ': '').' href="'.($link ? $link: 'javascript:void;').'">Tambah data</a></div>' ;
		}	
		if($task=='struktur_detail'){
			$sid = isset($_GET['sid']) ? $_GET['sid'] : 0 ;
			if( !is_max_struktur_gaji($sid)){
				$button .=  ' <div id="button_title"><a '.($popen ? 'rel="facebox" ': '').' href="'.($link ? $link: 'javascript:void;').'">Tambah data</a></div>' ;			
			}			
			$button .='<div id="button_title"><a href="index.php?com=struktur_gaji&task=auto&sid='.$sid.'">Auto</a></div>' ;
		}	
	}else{
		$cetaks = array('pos_biaya' , 'keluarga_jabatan');
		$cetak = $_GET['com'];
		if(in_array($cetak , $cetaks))
			$button .='<div id="button_title"><a href="javascript:void;" onclick="javascript:window.open(\'index.php?com=report&task=list_'.$_GET['com'].'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');">Cetak</a></div>' ;
	}
	
	$backs = array('jabatan',
		'kompetensi',
		'keluarga_jabatan',
		'struktur_gaji',
		'grievance',
		'pr_gol_jabatan',
		'pr_perawat',
		'unsur_evaluasi',
		'profesi',
		'pr_sk_tunjangan',
		'spd_jenis_non_karyawan',
		'yearly_income',
		);
	$back = $_GET['com'];
	$task = isset($_GET['task']) ? $_GET['task'] : "" ;
	$sk_id = isset($_GET['sk_id']) ? $_GET['sk_id'] : 0 ;
	$pid = isset($_GET['pid']) ? $_GET['pid'] : 0 ;
	$yearly_income_id  = isset( $_GET['yearly_income_id'] ) ? $_GET['yearly_income_id']:  0;
	if(in_array($back , $backs) && !isset($_GET['top'])){
		if($back =='jabatan'){
			if($task==""){
			}else{
				if(isset($_GET['parent_id'])){
					$jabatan = my_get_data_by_id('jabatan','jabatan_id',isset($_GET['parent_id']) ?$_GET['parent_id'] : 0);
					if($jabatan['parent_id']==0){
						$button .='<div id="button_title"><a href="index.php?com=jabatan
								&task=list_jabatan
								&sk_id='.$sk_id.'">Back</a></div>' ;					
					}else{
						$button .='<div id="button_title"><a href="index.php?com=jabatan
								&task=list_jabatan
								&sk_id='.$sk_id.'
								&parent_id='.$jabatan['parent_id'].'"
								>Back</a></div>' ;					
					}
				}else{
					$button .='<div id="button_title"><a href="index.php?com=jabatan">Back</a></div>' ;
				}
			}
		}elseif($back =='struktur_gaji'){
			if($task == "struktur_detail"){
				$button .='<div id="button_title"><a href="index.php?com=struktur_gaji">Back</a></div>' ;			
			}
		}elseif($back =='kompetensi'){ //KOMPETENSI	
			if($task == "list_kompetensi_indikator"){
				$retuntask = "list_kompetensi";
				$kompetensi = my_get_data_by_id('kompetensi','kompetensi_id',$_GET['pid']);
				$unit = my_get_data_by_id('kompetensi_unit','kompetensi_unit_id',$kompetensi['kompetensi_unit_id']); 
				
				$button .='<div id="button_title"><a href="index.php?com=kompetensi&task='.$retuntask.'&uid='.$kompetensi['kompetensi_unit_id'].'&kid='.$unit['kompetensi_kelompok_id'].'">Back</a></div>' ;
			}
			elseif($task == "list_kompetensi"){
				$retuntask = "list_kompetensi_unit";
				$unit = my_get_data_by_id('kompetensi_unit','kompetensi_unit_id',$_GET['uid']); 
				$button .='<div id="button_title"><a href="index.php?com=kompetensi&task='.$retuntask.'&kid='.$unit['kompetensi_kelompok_id'].'">Back</a></div>' ;
			
			}
			elseif($task == "list_kompetensi_unit"){
				$retuntask = "";
				
				$button .='<div id="button_title"><a href="index.php?com=kompetensi">Back</a></div>' ;
			
			}
		}elseif($back =='unsur_evaluasi'){ //unsur_evaluasi	
			if($task == "list_evaluasi"){
				$retuntask = "list_unsur_evaluasi";
				$unit = my_get_data_by_id('unsur_evaluasi','unsur_evaluasi_id',$_GET['uid']); 
				$button .='<div id="button_title"><a href="index.php?com=unsur_evaluasi&task='.$retuntask.'&penilaian_id='.$unit['penilaian_id'].'">Back</a></div>' ;
			
			}
			elseif($task == "list_unsur_evaluasi"){
				$retuntask = "";
				$button .='<div id="button_title"><a href="index.php?com=unsur_evaluasi">Back</a></div>' ;
			
			}			
		}elseif($back =='grievance'){ //GRIEVANCE	
			if($task == "list_grievance"){
				$retuntask = "list_grievance_sub";
				$unit = my_get_data_by_id('grievance_sub','grievance_sub_id',$_GET['sid']); 
				$button .='<div id="button_title"><a href="index.php?com=grievance&task='.$retuntask.'&kid='.$unit['grievance_kelompok_id'].'">Back</a></div>' ;
			
			}elseif($task == "list_grievance_sub"){
				$retuntask = "";
				$periode_id = my_get_data_by_id('grievance_kelompok','grievance_kelompok_id',$_GET['kid']); 
				$button .='<div id="button_title"><a href="index.php?com=grievance&task=list_grievance_kelompok&pid='.$periode_id['grievance_periode_id'].'">Back</a></div>' ;
			
			}elseif($task == "list_grievance_kelompok"){
				$retuntask = "";
				
				$button .='<div id="button_title"><a href="index.php?com=grievance">Back</a></div>' ;
			
			}		
		}elseif($back =='pr_gol_jabatan'){
			if($task == "list_gol_jabatan"){
				$button .='<div id="button_title"><a href="index.php?com=pr_gol_jabatan">Back</a></div>' ;			
			}
			
			if($task == "detail"){
				$button .='<div id="button_title"><a href="index.php?com=pr_gol_jabatan&task=list_gol_jabatan&sk_id='.$sk_id.'">Back</a></div>' ;			
			}
		}elseif($back =='pr_perawat'){
			if($task == "detail"){
				$button .='<div id="button_title"><a href="index.php?com=pr_perawat">Back</a></div>' ;			
			}	
		}elseif($back =='kalendar_shift'){
			if($task == "detail"){
				$button .='<div id="button_title"><a href="index.php?com=kalendar_shift">Back</a></div>' ;			
			}	
		}elseif($back =='unsur_evaluasi'){
			if($task == "list_evaluasi"){
				$button .='<div id="button_title"><a href="index.php?com=unsur_evaluasi">Back</a></div>' ;			
			}	
		}elseif($back =='profesi'){
			if($task == "list_profesi_detail"){
				$button .='<div id="button_title"><a href="index.php?com=profesi">Back</a></div>' ;			
			}	
		}elseif($back =='pr_sk_tunjangan'){
			if($task == "list_detail"){
				$button .='<div id="button_title"><a href="index.php?com=pr_sk_tunjangan">Back</a></div>' ;			
			}	
		}elseif($back =='spd_jenis_non_karyawan'){
			if($task == "list_golongan" OR $task == "list_tarif" OR $task == "list_keperluan"){
				$button .='<div id="button_title"><a href="index.php?com=spd_jenis_non_karyawan">Back</a></div>' ;			
			}	
			if($task == "list_kendaraan"){
				$jid=isset( $_GET['jid'] ) ? $_GET['jid']:  0;
				$button .='<div id="button_title"><a href="index.php?com=spd_jenis_non_karyawan&task=select_all_kendaraan&jid='.$jid.'">Semua</a></div>' ;			
				$button .='<div id="button_title"><a href="index.php?com=spd_jenis_non_karyawan">Back</a></div>' ;			
			}	
		}elseif($back =='yearly_income'){
			if($task == "list_yearly_group"){
				$button .='<div id="button_title"><a href="javascript:void;" onclick="javascript:window.open(\'index.php?com=yearly_income&task=plaincetak&yearly_income_id='.$_GET['yearly_income_id'] .'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');">Cetak</a></div>' ;
				$button .='<div id="button_title"><a href="index.php?com=yearly_income">Back</a></div>' ;	
			}	
			if($task == "list_komponen"){
				$button .='<div id="button_title"><a href="index.php?com=yearly_income
					&task=list_yearly_group&yearly_income_id='.$yearly_income_id.'
					">Back</a></div>' ;			
			}	

		}else{
			$button .='<div id="button_title"><a href="'.$_SERVER['HTTP_REFERER'].'">Back</a></div>' ;
		}
	}
	
	$view .= '<div id="admin_title">'.$pagename .$button.'</div><div style="clear:both"></div> <br/>';
	
	$view .=  $content.'</td>';
	$view .='</tr></table>';
	return $view;
}

function is_max_struktur_gaji($sid){
	$query="SELECT max(grade_id) as grade_id FROM struktur_gaji_detail
		WHERE struktur_gaji_id={$sid}"; 
	$strukturs = my_fetch_array(my_query($query))	;
	$query="SELECT max(grade_id) as grade_id FROM grade"; 
	$grades = my_fetch_array(my_query($query))	;
	if( (int) $strukturs['grade_id'] < (int) $grades['grade_id'] ){
		return false;
	}
	return true;
}	